package sistemasdistribuidos;

import classesBase.Animal;
import com.toedter.calendar.JDateChooser;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.text.SimpleDateFormat;
import telasMensagem.Bloqueio;
import telasMensagem.Concluido;
import telasMensagem.SimNao;

public class CadastroAnimal extends javax.swing.JDialog {

    SimpleDateFormat form = new SimpleDateFormat("yyyy-MM-dd");
    static boolean fecha = false;

    public CadastroAnimal(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        jTextFieldDono.setEditable(false);
        jTextPaneObservacoes.setEditable(true);
        jTextFieldCodDono.setEditable(false);
        jTextFieldCodigodoanimal.setEditable(false);
        /*
         Pegar o ultimo ID cadastrado no BD, soma  e setar no código
         */
        jTextFieldCodigodoanimal.setText("00001");

        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                SimNao sn = new SimNao(null, true, "<html>Tem certeza que deseja "
                        + "sair sem salvar o cadastro? Todos os dados inseridos "
                        + "serão perdidos!<html>", 14);
                sn.setLocationRelativeTo(null);
                sn.setVisible(true);
                if (fecha == true) {
                    dispose();
                }
            }
        }
        );
    }

    public static void fechar(boolean fe) {
        fecha = fe;
    }

    public void racas(String animal) {
        jComboBoxRaca.removeAllItems();
        byte i = 0;
        jComboBoxRaca.addItem("Selecione");
        jComboBoxRaca.addItem(animal);
    }

    public static void limpar() {
        jTextFieldNome.setText(null);
        jTextFieldDono.setText(null);
        jComboBoxEspecie.setSelectedIndex(0);
        jComboBoxRaca.setSelectedIndex(0);
        jTextFieldPeso.setText(null);
        jDateChooserNascimento.setDate(null);
        jTextFieldRegistro.setText(null);
        jTextPaneObservacoes.setText(null);
        jTextFieldCodDono.setText(null);
    }

    public static void informacoes(String idDono, String nome) {
        jTextFieldDono.setText(nome);
        jTextFieldCodDono.setText(idDono);
    }

    public void bl(String msg) {
        Bloqueio blo = new Bloqueio(null, true, msg);
        blo.setLocationRelativeTo(null);
        blo.setVisible(true);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jLabelMsg13 = new javax.swing.JLabel();
        jTextFieldCodigodoanimal = new javax.swing.JTextField();
        jLabelMsg3 = new javax.swing.JLabel();
        jTextFieldNome = new javax.swing.JTextField();
        jTextFieldDono = new javax.swing.JTextField();
        jLabelMsg14 = new javax.swing.JLabel();
        jLabelMsg15 = new javax.swing.JLabel();
        jLabelMsg16 = new javax.swing.JLabel();
        jTextFieldPeso = new javax.swing.JTextField();
        jLabelMsg11 = new javax.swing.JLabel();
        jComboBoxEspecie = new javax.swing.JComboBox();
        jComboBoxRaca = new javax.swing.JComboBox();
        jLabelMsg12 = new javax.swing.JLabel();
        jRadioButtonFeminino = new javax.swing.JRadioButton();
        jRadioButtonMasculino = new javax.swing.JRadioButton();
        jLabelMsg9 = new javax.swing.JLabel();
        jLabelMsg18 = new javax.swing.JLabel();
        jTextFieldRegistro = new javax.swing.JTextField();
        jLabelMsg19 = new javax.swing.JLabel();
        jButtonSalvarCadastro = new javax.swing.JButton();
        jButtonLimparDados = new javax.swing.JButton();
        jButtonBuscar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane6 = new javax.swing.JScrollPane();
        jTextPaneObservacoes = new javax.swing.JTextPane();
        jButtonNovoCliente = new javax.swing.JButton();
        jTextFieldCodDono = new javax.swing.JTextField();
        jDateChooserNascimento = new com.toedter.calendar.JDateChooser();
        jLabelMsg17 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Cadastro Animal");
        setModal(true);
        setName("CadastroAnimais"); // NOI18N

        jPanel1.setBackground(new java.awt.Color(255, 102, 0));
        jPanel1.setBorder(javax.swing.BorderFactory.createMatteBorder(3, 3, 3, 3, new java.awt.Color(0, 0, 0)));

        jLabelMsg13.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg13.setText("Código do Animal:");

        jTextFieldCodigodoanimal.setEditable(false);
        jTextFieldCodigodoanimal.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldCodigodoanimal.setText("000001");

        jLabelMsg3.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg3.setText("Nome:");

        jTextFieldNome.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldNome.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTextFieldNomeMouseClicked(evt);
            }
        });

        jTextFieldDono.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jTextFieldDono.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldDonoActionPerformed(evt);
            }
        });

        jLabelMsg14.setFont(new java.awt.Font("Segoe UI", 1, 36)); // NOI18N
        jLabelMsg14.setText("Cadastro de Animais");

        jLabelMsg15.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg15.setText("Peso:");

        jLabelMsg16.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg16.setText("Raça:");

        jTextFieldPeso.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N

        jLabelMsg11.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg11.setText("Espécie:");

        jComboBoxEspecie.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jComboBoxEspecie.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecione", "Cão", "Gato", "Pássaro", "Roedor" }));
        jComboBoxEspecie.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jComboBoxEspecie.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxEspecieActionPerformed(evt);
            }
        });

        jComboBoxRaca.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jComboBoxRaca.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecione" }));
        jComboBoxRaca.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jComboBoxRaca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBoxRacaActionPerformed(evt);
            }
        });

        jLabelMsg12.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg12.setText("Sexo:");

        jRadioButtonFeminino.setBackground(new java.awt.Color(255, 102, 0));
        buttonGroup1.add(jRadioButtonFeminino);
        jRadioButtonFeminino.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jRadioButtonFeminino.setSelected(true);
        jRadioButtonFeminino.setText("Fêmea");

        jRadioButtonMasculino.setBackground(new java.awt.Color(255, 102, 0));
        buttonGroup1.add(jRadioButtonMasculino);
        jRadioButtonMasculino.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jRadioButtonMasculino.setText("Macho");

        jLabelMsg9.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg9.setText("Data de Nascimento:");

        jLabelMsg18.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg18.setText("Registro:");

        jTextFieldRegistro.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N

        jLabelMsg19.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg19.setText("Observações:");

        jButtonSalvarCadastro.setBackground(new java.awt.Color(255, 255, 255));
        jButtonSalvarCadastro.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonSalvarCadastro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/pata.png"))); // NOI18N
        jButtonSalvarCadastro.setText("Salvar Cadastro");
        jButtonSalvarCadastro.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonSalvarCadastro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSalvarCadastroActionPerformed(evt);
            }
        });

        jButtonLimparDados.setBackground(new java.awt.Color(255, 255, 255));
        jButtonLimparDados.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonLimparDados.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/limpar.png"))); // NOI18N
        jButtonLimparDados.setText("Limpar Dados");
        jButtonLimparDados.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonLimparDados.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonLimparDadosActionPerformed(evt);
            }
        });

        jButtonBuscar.setBackground(new java.awt.Color(255, 255, 255));
        jButtonBuscar.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Busca_Icon.png"))); // NOI18N
        jButtonBuscar.setToolTipText("Clique para buscar o responsável pelo animal a ser cadastrado");
        jButtonBuscar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarActionPerformed(evt);
            }
        });

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/dog.png"))); // NOI18N

        jTextPaneObservacoes.setEditable(false);
        jTextPaneObservacoes.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jScrollPane6.setViewportView(jTextPaneObservacoes);

        jButtonNovoCliente.setBackground(new java.awt.Color(255, 255, 255));
        jButtonNovoCliente.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N
        jButtonNovoCliente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/pata.png"))); // NOI18N
        jButtonNovoCliente.setText("Novo Cliente");
        jButtonNovoCliente.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButtonNovoCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonNovoClienteActionPerformed(evt);
            }
        });

        jTextFieldCodDono.setEditable(false);
        jTextFieldCodDono.setFont(new java.awt.Font("Segoe UI", 0, 16)); // NOI18N

        jDateChooserNascimento.setBackground(new java.awt.Color(255, 102, 0));
        jDateChooserNascimento.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N

        jLabelMsg17.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N
        jLabelMsg17.setText("<html><u>Dono:<u></html>");
        jLabelMsg17.setToolTipText("Abrir Cadastro");
        jLabelMsg17.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabelMsg17.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabelMsg17MouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jLabelMsg14)
                .addGap(129, 129, 129))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabelMsg13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTextFieldCodigodoanimal, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelMsg3)
                            .addComponent(jLabelMsg17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jTextFieldDono)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextFieldCodDono, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButtonBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jTextFieldNome, javax.swing.GroupLayout.PREFERRED_SIZE, 494, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(jButtonNovoCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(27, 27, 27)
                            .addComponent(jButtonSalvarCadastro, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(31, 31, 31)
                            .addComponent(jButtonLimparDados))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabelMsg19))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabelMsg11)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jComboBoxEspecie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(14, 14, 14)
                                    .addComponent(jLabelMsg16)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jComboBoxRaca, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addComponent(jLabelMsg15)
                                            .addGap(18, 18, 18)
                                            .addComponent(jTextFieldPeso, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(18, 18, 18)
                                            .addComponent(jLabelMsg9))
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addGap(4, 4, 4)
                                            .addComponent(jLabelMsg12)
                                            .addGap(18, 18, 18)
                                            .addComponent(jRadioButtonFeminino)
                                            .addGap(18, 18, 18)
                                            .addComponent(jRadioButtonMasculino)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jLabelMsg18)))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(jTextFieldRegistro, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                            .addComponent(jDateChooserNascimento, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addGap(3, 3, 3))))
                                .addComponent(jScrollPane6)))))
                .addContainerGap(29, Short.MAX_VALUE))
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButtonLimparDados, jButtonSalvarCadastro});

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addComponent(jLabelMsg14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMsg13)
                    .addComponent(jTextFieldCodigodoanimal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMsg3)
                    .addComponent(jTextFieldNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jTextFieldDono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jTextFieldCodDono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabelMsg17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jButtonBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(15, 15, 15)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelMsg11)
                            .addComponent(jComboBoxEspecie, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelMsg16)
                            .addComponent(jComboBoxRaca, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextFieldPeso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelMsg9, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelMsg15)
                            .addComponent(jDateChooserNascimento, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(28, 28, 28)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelMsg12)
                            .addComponent(jRadioButtonFeminino)
                            .addComponent(jRadioButtonMasculino)
                            .addComponent(jLabelMsg18, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextFieldRegistro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabelMsg19, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 32, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButtonSalvarCadastro, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonLimparDados)
                    .addComponent(jButtonNovoCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(21, 21, 21))
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jButtonLimparDados, jButtonSalvarCadastro});

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        getAccessibleContext().setAccessibleName("");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTextFieldNomeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTextFieldNomeMouseClicked
        jTextFieldNome.setText(null);
    }//GEN-LAST:event_jTextFieldNomeMouseClicked

    private void jTextFieldDonoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldDonoActionPerformed

    }//GEN-LAST:event_jTextFieldDonoActionPerformed

    private void jComboBoxEspecieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxEspecieActionPerformed
        if (!jComboBoxEspecie.getSelectedItem().equals("Selecione")) {

            if (jComboBoxEspecie.getSelectedItem().equals("Cão")) {
                racas("Cão");
            }
            if (jComboBoxEspecie.getSelectedItem().equals("Gato")) {
                racas("Gato");
            }
            if (jComboBoxEspecie.getSelectedItem().equals("Pássaro")) {
                racas("Pássaro");
            }
            if (jComboBoxEspecie.getSelectedItem().equals("Roedor")) {
                racas("Roedor");
            }
        } else {
            jComboBoxRaca.removeAllItems();
            jComboBoxRaca.addItem("Selecione");

        }
    }//GEN-LAST:event_jComboBoxEspecieActionPerformed

    private void jButtonSalvarCadastroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSalvarCadastroActionPerformed
        Animal animal = new Animal();
        animal.setIdAnimal(Integer.parseInt(jTextFieldCodigodoanimal.getText()));
        animal.setNome(jTextFieldNome.getText());
        animal.setEspecie((String) jComboBoxEspecie.getSelectedItem());
        animal.setRaca((String) jComboBoxRaca.getSelectedItem());
        animal.setPeso(jTextFieldPeso.getText());
        try {
            animal.setNascimento(form.format(jDateChooserNascimento.getDate()));
        } catch (Exception ex) {
            animal.setNascimento(null);
        }
        if (jRadioButtonFeminino.isSelected() == true) {
            animal.setSexo("Femea");
        } else {
            animal.setSexo("Macho");
        }
        animal.setRegistro(jTextFieldRegistro.getText());
        animal.setObs(jTextPaneObservacoes.getText());

        if (animal.getNome().length() == 0) {
            bl("<html>Nenhum nome foi inserido! <br>"
                    + "Por favor, informe o nome do animal antes"
                    + " de prosseguir!</html>");
        } else {
            if (animal.getEspecie().equals("Selecione")) {
                bl("<html>Nenhuma espécie foi selecionada! <br>"
                        + "Por favor, selecione a espécie do animal antes"
                        + " de prosseguir!</html>");
            } else {
                if (animal.getRaca().equals("Selecione")) {
                    bl("<html>Nenhuma raça foi selecionada! <br>"
                            + "Por favor, selecione a raça do animal antes"
                            + " de prosseguir!</html>");
                } else {

                    try {
                        animal.setIdDono(Integer.parseInt(jTextFieldCodDono.getText()));
                        /*
                         Salvar no Banco de Dados
                         */
                        limpar();
                        Concluido co = new Concluido(null, true, "<html>Animal cadastrado "
                                + "com sucesso! <br>"
                                + "Para consultar o cadastro vá até a tela "
                                + " de Animais Cadastrados!</html>");
                    } catch (Exception ex) {
                        bl("<html>Nenhum cliente foi selecionado! <br>"
                                + "Por favor, selecione o cliente responsável pelo "
                                + "mesmo antes de prosseguir!</html>");
                    }
                }
            }
        }

    }//GEN-LAST:event_jButtonSalvarCadastroActionPerformed

    private void jButtonLimparDadosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLimparDadosActionPerformed
        SimNao sn = new SimNao(null, true, "<html>Tem certeza que deseja apagar todas"
                + " as informações inseridas nos campos?<html>", 3);
        sn.setLocationRelativeTo(null);
        sn.setVisible(true);
    }//GEN-LAST:event_jButtonLimparDadosActionPerformed

    private void jButtonBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarActionPerformed
        ClientesCadastrados c = new ClientesCadastrados(null, true, 0);
        c.setLocationRelativeTo(null);
        c.setVisible(true);
    }//GEN-LAST:event_jButtonBuscarActionPerformed

    private void jComboBoxRacaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxRacaActionPerformed

    }//GEN-LAST:event_jComboBoxRacaActionPerformed

    private void jButtonNovoClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonNovoClienteActionPerformed
        CadastroCliente cc = new CadastroCliente(null, true);
        cc.setLocationRelativeTo(null);
        cc.setVisible(true);
    }//GEN-LAST:event_jButtonNovoClienteActionPerformed

    private void jLabelMsg17MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabelMsg17MouseClicked
        if (jTextFieldDono.getText().length() > 0) {
            //Abrir ficha do cliente
        }
    }//GEN-LAST:event_jLabelMsg17MouseClicked

    public static void main(String args[]) {

        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CadastroAnimal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CadastroAnimal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CadastroAnimal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CadastroAnimal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                CadastroAnimal dialog = new CadastroAnimal(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton jButtonBuscar;
    private javax.swing.JButton jButtonLimparDados;
    private javax.swing.JButton jButtonNovoCliente;
    private javax.swing.JButton jButtonSalvarCadastro;
    public static javax.swing.JComboBox jComboBoxEspecie;
    public static javax.swing.JComboBox jComboBoxRaca;
    public static com.toedter.calendar.JDateChooser jDateChooserNascimento;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabelMsg11;
    private javax.swing.JLabel jLabelMsg12;
    private javax.swing.JLabel jLabelMsg13;
    private javax.swing.JLabel jLabelMsg14;
    private javax.swing.JLabel jLabelMsg15;
    private javax.swing.JLabel jLabelMsg16;
    private javax.swing.JLabel jLabelMsg17;
    private javax.swing.JLabel jLabelMsg18;
    private javax.swing.JLabel jLabelMsg19;
    private javax.swing.JLabel jLabelMsg3;
    private javax.swing.JLabel jLabelMsg9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButton jRadioButtonFeminino;
    private javax.swing.JRadioButton jRadioButtonMasculino;
    private javax.swing.JScrollPane jScrollPane6;
    public static javax.swing.JTextField jTextFieldCodDono;
    public static javax.swing.JTextField jTextFieldCodigodoanimal;
    public static javax.swing.JTextField jTextFieldDono;
    public static javax.swing.JTextField jTextFieldNome;
    public static javax.swing.JTextField jTextFieldPeso;
    public static javax.swing.JTextField jTextFieldRegistro;
    public static javax.swing.JTextPane jTextPaneObservacoes;
    // End of variables declaration//GEN-END:variables
}
